VERSION=''
re="\"(version)\": \"([^\"]*)\""

while read -r l; do
  if [[ $l =~ $re ]]; then
    value="${BASH_REMATCH[2]}"
    VERSION="$value"
  fi
done <package.json

# 名称跟随后台取名
NAME="xxx"
PROJECT="${NAME}-frontend"

CURRENT_DAY=$(date +%Y%m%d)

BUILD_PACKAGE="${PROJECT}-v${VERSION}"

SVN_FOLDER="${PROJECT}-v${VERSION}-${CURRENT_DAY}"

rm -rf ${SVN_FOLDER}

mkdir ${SVN_FOLDER}

#npm run build

# 新版 配合docker打包规范
cp -r html ${NAME}

tar  -zcvf ${BUILD_PACKAGE}.tar.gz ./${NAME}

mv ${BUILD_PACKAGE}.tar.gz ./${SVN_FOLDER}

cp -r ./deploy/. ./${SVN_FOLDER}/

rm -rf ${NAME}

# 修改文件说明
cd ./${SVN_FOLDER}/

DOCKER_IMAGE=harbor.topvdn.com/develop_version/wsd/${PROJECT}:${VERSION}-alpine

sed -i "s#tar-project#${BUILD_PACKAGE}#g;s#docker-project#${DOCKER_IMAGE}#g" AID分拣服务项目前端部署文档.md


# 修改docker-run的名称和版本号
sed -i "s/1.0.0/${VERSION}/g;s/project/${NAME}/g" docker-run.sh


# 替换dockerfile版本号和名称
sed -i "s/v1.0.0/v${VERSION}/g;s/project/${NAME}/g" Dockerfile
